/**
 * 
 */
package com.android.calldelay.receiver;

import java.lang.reflect.Method;

import com.android.internal.telephony.ITelephony;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.RemoteException;
import android.telephony.TelephonyManager;
import android.util.Log;

/**
 * @author INVEERA
 *
 */
public class OnCallConnectReceave extends BroadcastReceiver {

	private static final String LOG_TAG = null;
	private ITelephony telephonyService;

	/* (non-Javadoc)
	 * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
	 */
	@Override
	public void onReceive(Context context, Intent intent) {
	//	Toast.makeText(context, "Disconnected", Toast.LENGTH_SHORT).show();
		TelephonyManager tm = (TelephonyManager) context
		        .getSystemService(Context.TELEPHONY_SERVICE);
		try {
		    // Java reflection to gain access to TelephonyManager's
		    // ITelephony getter
		    Log.v("Tag", "Get getTeleService...");
		    Class c = Class.forName(tm.getClass().getName());
		    Method m = c.getDeclaredMethod("getITelephony");
		    m.setAccessible(true);
		     telephonyService = (ITelephony)m.invoke(tm);
		} catch (Exception e) {
		    e.printStackTrace();
		    Log.e(LOG_TAG,
		            "FATAL ERROR: could not connect to telephony subsystem");
		    Log.e(LOG_TAG, "Exception object: " + e);
		}
	 

		try {
			
			telephonyService.call("5556");
			 			 
			 
		 
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
